<div class="row">
    <div class="col-md-12">
        <h1>Rao vặt <small>Danh sách tin rao vặt</small></h1>
        <ol class="breadcrumb">
            <li><a href="<?php echo mns_page_url(); ?>"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li class="active"><a href="<?php echo mns_page_url(RAOVAT_SLUG); ?>"><i class="fa fa-table"></i> Rao vặt</a></li>
        </ol>
    </div>
</div>

<div class="row">
    <div class="col-md-6 col-xs-12 mgt5">
        <form method="get" action="<?php echo mns_page_url(RAOVAT_SLUG.'/tim-kiem'); ?>" enctype="multipart/form-data">
            <div class="input-group">
                <input type="text" class="form-control" name="s" value="<?php echo isset($searchkey)?$searchkey:''; ?>" placeholder="Tìm kiếm" />
                <span class="input-group-btn">
                    <button class="btn btn-success" type="submit"><i class="fa fa-search"></i> Tìm kiếm!</button>
                </span>
            </div><!-- /input-group -->
        </form>
    </div>

    <div class="col-md-6 col-xs-12">
        <p class="pull-right">
            <a class="btn btn-success" href="<?php echo mns_page_url(RAOVAT_SLUG.'/them'); ?>">
                <i class='glyphicon glyphicon-plus-sign'></i> Thêm tin mới
            </a>
            <a class="btn btn-default" href="<?php echo mns_page_url(RAOVAT_SLUG, array('f'=>'trash')); ?>"><i class="fa fa-trash-o"></i> Không hiển thị</a>
        </p>
    </div>
    <div class="clearfix"></div>

    <div class="col-md-12 col-xs-12">
        <?php echo $pagingBar; ?>
    </div>

    <div class="col-md-12">
        <div class="table-responsive">
            <table class="table table-bordered table-hover tablesorter item-list" data-href='<?php echo mns_page_url(RAOVAT_SLUG.'/cap-nhat-trang-thai'); ?>'>
                <thead>
                    <tr>
                        <th class="header"># <i class="fa fa-sort"></i></th>
                        <th class="header">&nbsp;</th>
                        <th class="header">Tin rao vặt <i class="fa fa-sort"></i></th>
                        <th class="header">Danh mục <i class="fa fa-sort"></i></th>
                        <th class="header">Nơi áp dụng <i class="fa fa-sort"></i></th>
                        <th class="header visible-md visible-lg" style="width:20%;">Mô tả <i class="fa fa-sort"></i></th>
                        <th class="header">Số lần xem <i class="fa fa-sort"></i></th>
                        <th class="header">&nbsp;</th>
                    </tr>
                    <tr class="tr-temp hidden warning">
                        <td colspan="6">
                            <form role="form" method="post" action="<?php echo mns_page_url(RAOVAT_SLUG.'/cap-nhat'); ?>">
                                <div class="row">
                                    <div class="col-md-7">
                                        <div class="form-group">
                                            <label for="input-raovat-title">Tên danh mục</label>
                                            <input type="text" class="form-control" id="input-raovat-title" name="category[title]" value="" />
                                        </div>
                                        <div class="form-group">
                                            <label for="input-raovat-slug">Đường dẫn</label>
                                            <input type="text" class="form-control" id="input-raovat-slug" name="category[slug]" value="" />
                                        </div>
                                        <div class="form-group">
                                            <label for="input-raovat-cate">Danh mục cha</label>
                                            <select class="form-control" id="input-raovat-cate" name="category[cate_flh]">
                                                <?php foreach($aParentCate as $pCate) { ?>
                                                <option value="<?php echo $pCate->getId(); ?>" data-href="<?php echo category_url($pCate->getSlug()); ?>">
                                                    <?php echo $pCate->getTitle(); ?>
                                                </option>
                                                <?php } ?>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label for="input-raovat-order">Thứ tự</label>
                                            <input type="text" class="form-control" id="input-raovat-order" name="category[order]" value="" />
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="checkbox">
                                            <label for="input-raovat-delete-flg">
                                                <input type="checkbox" id="input-raovat-delete-flg" name="category[delete_flg]" value="1"/> Xoá
                                            </label>
                                        </div>
                                    </div>
                                    <div class="col-md-2">
                                        <input type="hidden" name="category[id]" id="input-raovat-id" />
                                        <button type="button" class="btn btn-success btn-submit-update">Cập nhật</button>
                                        <button type="button" class="btn btn-danger btn-cancel-update">Huỷ</button>
                                    </div>
                                </div>
                            </form>
                        </td>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach($aRaoVat as $index=>$r) { ?>
                    <tr class="can-edit" data-id="<?php echo $this->encrypt->encode($r->getId()); ?>">
                        <th class="header bg-info"><?php echo $index+1; ?></th>
                        <td class="input-raovat-img">
                            <a class="thumbnail" href="<?php echo mns_raovat_single_url($r->getSlug()); ?>" title="<?php echo $r->getTitle(); ?>">
                                <?php if($r->getImage()!=null) { ?>
                                <img class="has-border" src="<?php echo raovat_upload($r->getImage(), $r->image_folder); ?>" alt='<?php echo $r->getTitle(); ?>' />
                                <?php } else { ?>
                                <img class="has-border" data-src="holder.js/96x96/text:Hình đại diện" alt='<?php echo $r->getTitle(); ?>' />
                                <?php } ?>
                            </a>
                        </td>
                        <td class="input-raovat-title">
                            <h4>
                                <a class="raovat-title text-capitalize" href="<?php echo mns_raovat_single_url($r->getSlug()); ?>">
                                    <?php echo $r->getTitle(); ?>
                                </a>
                            </h4>
                            <p><em><?php echo fdate_format($r->getCreatedAt()); ?></em></p>
                        </td>
                        <td class="input-raovat-cate" data-cate-id="<?php echo $r->getCateId(); ?>">
                            <a target="_blank" href="<?php echo category_url($r->cate_slug); ?>"><?php echo $r->cate_title; ?></a>
                        </td>
                        <td><?php echo $r->place_name; ?></td>
                        <td class="visible-md visible-lg"><?php echo $r->getDescription(); ?></td>
                        <td class="input-raovat-viewtime"><?php echo $r->getViewTime(); ?></td>
                        <td class="input-raovat-flg">
                            <div class="checkbox">
                                <input id="chk-active-<?php echo $index+1; ?>" class="input-raovat-active-flg lb-toggle" data-name="active_flg" type="checkbox"  value="1"
                                <?php echo $r->getActiveFlg()==1 ?"checked='checked'":''; ?> /> Hiển thị
                                <label for="chk-active-<?php echo $index+1; ?>"></label>
                            </div>
                            <div class="checkbox">
                                <input id="chk-delete-<?php echo $index+1; ?>" class="input-raovat-delete-flg lb-toggle red" data-name="delete_flg" type="checkbox"  value="1"
                                <?php echo $r->getDeletedAt()!=NULL ?"checked='checked'":''; ?> />
                                Xoá
                                <label for="chk-delete-<?php echo $index+1; ?>"></label>
                            </div>
                        </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>
        </div>
    </div>
    <div class="clearfix"></div>
</div>